<template>
  <div class="chatgpt">
    <Load v-if="isLoad" />
    <div class="main" v-else>
      <iframe
        :src="url"
        style="width: 100%; height: calc(100vh - 63px)"
      ></iframe>
    </div>
  </div>
</template>

<script setup>
import request from "@/utils/request";
import Load from "@/components/Load.vue";
import { onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import { ElMessage } from "element-plus";
const $router = useRouter();
const url = "http://8.134.121.53:8080/chat/";
const isLoad = ref(true);

onMounted(() => {
  let permission = JSON.parse(localStorage.getItem("USER_PERMISSION"));
  let status = null;
  permission.forEach((item) => {
    console.log(item);
    if (item == "chatgpt") {
      status = true;
    }
  });
  if (!status) {
    setTimeout(() => {
      $router.go(-1);
      ElMessage.warning("暂无权限，请向管理员申请权限");
    }, 4000);
  } else {
    setTimeout(() => {
      isLoad.value = false;
    }, 4000);
  }
});
</script>

<style scoped lang="scss">
.chatgpt {
  width: 100%;
  min-height: calc(100vh - 63px);
  display: flex;
  align-items: center;
  overflow-x: hidden;
  .main {
    width: 100%;
  }
}
</style>